package com.choudou5.solr.bean;

import com.choudou5.solr.bean.common.BaseUserBean;
import com.choudou5.solr.framework.bean.UserBean;
import com.choudou5.solr.framework.bean.UserSessionBean;
import com.choudou5.solr.framework.constants.SysConsts;

import java.util.Date;

/**
 * @name 系统动态
 * @author choudou5
 * @date 2018-7-13
 */
public class SysDynamicBean extends BaseUserBean<Long> {

    private Long id;
    /**
     * 动作
     */
    private String action;
    /**
     * 主题
     */
    private String subject;
    /**
     * desc 说明
     */
    private String desc;

    private String ip;


    public SysDynamicBean() {
    }

    public SysDynamicBean(Long id) {
        this.id = id;
    }

    public SysDynamicBean(SysConsts.ActionType action, String subject, UserBean user) {
        this(action, subject, user.getId(), user.getLoginIp());
    }

    public SysDynamicBean(SysConsts.ActionType action, String subject, UserSessionBean user) {
        this(action, subject, user.getId(), user.getLoginIp());
    }

    public SysDynamicBean(SysConsts.ActionType action, String subject, Integer userId, String ip) {
        this.action = action.getKey();
        this.subject = subject;
        this.ip = ip;
        setCreateBy(userId);
        setCreateTime(new Date());
    }

    public SysDynamicBean(SysConsts.ActionType action, String subject, String desc, UserSessionBean user) {
        this.action = action.getKey();
        this.subject = subject;
        this.desc = desc;
        this.ip = user.getLoginIp();
        setCreateBy(user.getId());
        setCreateTime(new Date());
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }
}
